﻿@using PagedList.Mvc;
@{
    PagedList.IPagedList<Model.CodeManage.GenCodeModel> myPageList = (PagedList.IPagedList<Model.CodeManage.GenCodeModel>)ViewBag.MyPageList;
    Layout = "~/Views/Shared/MyLayOutNew.cshtml";
}


<link href="~/Content/PagedList.css" rel="stylesheet" />
<main class="main-cont content mCustomScrollbar">
    <div class="page-wrap">
        <!--开始::内容-->
        <section class="page-hd">
            <header>
                <h2 class="title">码下载>>码下载</h2>
                <div class="fr input-group">
                    <input id="inputTxt" type="text" class="form-control" placeholder="生码批次或机构名称..." style="width:290px;" />
                    <button class="btn btn-secondary-outline" onclick="seacrh()">搜索</button>
                </div>
            </header>
            <hr>
        </section>
        <table class="table mb-15">
            <thead>
                <tr>
                    <th><input type="checkbox" /></th>
                    <th>公司名称</th>
                    <th>机构代码</th>
                    <th>生码批次</th>
                    <th>生码数量</th>
                    <th>生码状态</th>
                    <th>生码类型</th>
                    <th>生码时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>

                @foreach (var item in myPageList)
                {
                    <tr class="cen">
                        <td><input type="checkbox" /></td>
                        <td>
                           
                            @Html.DisplayFor(modelItem => item.EnterpriseName)
                        </td>
                        <td>
                           @Html.DisplayFor(modelItem=>item.EnterpriseCode)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Batch)
                        </td>

                        <td>
                            @Html.DisplayFor(modelItem => item.Gen_Code_Nums)
                        </td>


                        <td>
                            @Html.DisplayFor(modelItem => item.Status)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CodeTypeText)
                        </td>

                        <td>
                            @Html.DisplayFor(modelItem => item.CreateDate)
                        </td>

                        <td>
                            <a title="下载" class="mr-5" onclick="DownLoad('@item.PatchId','@item.Status','@item.EnterpriseName');">下载</a>
                             
                        </td>
                    </tr>
                }

            </tbody>
        </table>
        每页 @myPageList.PageSize 条记录，共 @myPageList.PageCount 页，当前第 @myPageList.PageNumber 页
        @Html.PagedListPager(myPageList, page => Url.Action("DownCode", new { page }))
        <!--开始::结束-->
    </div>
</main>


<div class="mask"></div>
<div class="dialog">
    <div class="dialog-hd">
        <strong class="lt-title">系统提示</strong>
        <a class="rt-operate icon-remove JclosePanel" title="关闭"></a>
    </div>
    <div class="dialog-bd">
        <!--start::-->
        <p>未生码或生码未成功,无法下载！</p>
        <!--end::-->
    </div>
    <div class="dialog-ft">
        <button class="btn btn-info JyesBtn">确认</button>
        <button class="btn btn-secondary JnoBtn">关闭</button>
    </div>
</div>


<script type="text/javascript">
    function seacrh() {
        var str = $("#inputTxt").val();
        window.location.href = "/GenCode/DownCode?page=1&term=" + str;
    }
    function DownLoad(PatchId, Status,Name) {
      debugger
        if (Status != '成功') {//未生码或生码未成功
            $('.dialog,.mask').show();
            $('.dialog').css('box-shadow','none');
            return;
        }
        else {//成功生码状态
            //下载码的信息
            window.open("/DownLoad/ExportCode?BatchId=" + PatchId + "&key=5RUBGJSDG&companyName=" + Name);
        }
 
    }
</script>

